package study.HL7;

import ca.uhn.hl7v2.model.v23.message.ADT_A01;
import ca.uhn.hl7v2.model.v23.message.ORU_R01;
import ca.uhn.hl7v2.parser.PipeParser;

//import ca.uhn.hl7v2.model.v26.message.ADT_A01;
//import ca.uhn.hl7v2.model.v26.message.DSR_Q03;
//import ca.uhn.hl7v2.model.v26.message.ORU_R01;
//import ca.uhn.hl7v2.model.v26.message.QRY_Q02;
//import ca.uhn.hl7v2.model.v26.segment.PID;

/**
 * @Author 刘伟涛
 * @Date 2024/8/5 14:28
 **/
public class Demo01 {
    public static void main(String[] args) throws Exception {
        // 创建一个ADT_A01消息（患者入院）
        ADT_A01 adt_a01 = new ADT_A01();
        ORU_R01 adtMessage = new ORU_R01();
        adt_a01.initQuickstart("ADT", "A01", "P");

        // 设置PID段
/*        PID pid = adt_a01.getPID();
        pid.getPatientName(0).getFamilyName().setValue("Doe");
        pid.getPatientName(0).getGivenName().setValue("John");*/

        // 将消息转换为字符串格式
        PipeParser parser = new PipeParser();
        String encodedMessage = parser.encode(adt_a01);



        // 输出HL7消息
        System.out.println("HL7 Message:\n" + adt_a01);
    }
}
